{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "73bd968b-d970-4a05-94ef-4e7abf990827",
   "metadata": {},
   "source": [
    "Chapter 02\n",
    "\n",
    "# 乘法\n",
    "Book_3《数学要素》 | 鸢尾花书：从加减乘除到机器学习 (第二版)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "57f8b381-c7ec-4a36-a46f-33245d8367be",
   "metadata": {},
   "source": [
    "该代码计算两个数字的乘积并输出结果。首先定义了两个数字$2$和$3$，分别赋值给变量`num1`和`num2`。然后通过乘法运算求出它们的乘积。\n",
    "\n",
    "### 代码细节\n",
    "\n",
    "1. **乘积计算**：代码通过`num1 * num2`计算乘积，将结果存储在变量`prod`中。乘积公式为：\n",
    "\n",
    "   $$\n",
    "   \\text{prod} = \\text{num1} \\times \\text{num2} = 2 \\times 3 = 6\n",
    "   $$\n",
    "\n",
    "2. **结果显示**：代码使用格式化字符串将计算结果输出到屏幕，最终显示为“`The product of 2 and 3 is 6`”。\n",
    "\n",
    "### 总结\n",
    "\n",
    "这段代码展示了基本的乘法运算，将两个数字相乘并格式化输出。这种简单的乘积计算在数学运算和数值展示中广泛应用。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "59b86f9a-b73a-48b8-974a-ba5803676864",
   "metadata": {},
   "source": [
    "## 计算两个数字的乘积并显示结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ae82d0c3-5670-413a-ad3a-9e80ae494d7c",
   "metadata": {},
   "outputs": [],
   "source": [
    "num1 = 2  # 定义第一个数字"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "ad1f4552-a706-47f7-ab80-f99cffdb2176",
   "metadata": {},
   "outputs": [],
   "source": [
    "num2 = 3  # 定义第二个数字"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fdc5db12-93fa-48fd-a91e-8544fdb5d155",
   "metadata": {},
   "source": [
    "## 计算两个数字的乘积"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "18c7fedf-3881-43ed-97d4-c881d70d4665",
   "metadata": {},
   "outputs": [],
   "source": [
    "prod = num1 * num2  # 计算num1和num2的乘积"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4fe3ac7f-34f6-4588-9d8b-d68abe35e257",
   "metadata": {},
   "source": [
    "## 显示计算结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "121bb6c5-683f-4eeb-9217-0fb893147c6c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The product of 2 and 3 is 6\n"
     ]
    }
   ],
   "source": [
    "print('The product of {0} and {1} is {2}'.format(num1, num2, prod))  # 输出两个数字的乘积"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "85a80909-2aac-49ed-bb7a-f8cc6b80ee7d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ecd322f4-f919-4be2-adc3-69d28ef25e69",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
